package com.ruoyi.web.wx.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.wx.mapper.WxUserMapper;
import com.ruoyi.web.wx.entity.WxUser;
import com.ruoyi.web.wx.service.IWxUserService;
import com.ruoyi.common.core.text.Convert;

/**
 * 微信用户 服务层实现
 * 
 * @author ruoyi
 * @date 2019-08-27
 */
@Service
public class WxUserServiceImpl implements IWxUserService 
{
	@Autowired
	private WxUserMapper wxUserMapper;

	/**
     * 查询微信用户信息
     * 
     * @param id 微信用户ID
     * @return 微信用户信息
     */
    @Override
	public WxUser selectWxUserById(String id)
	{
	    return wxUserMapper.selectWxUserById(id);
	}
	
	/**
     * 查询微信用户列表
     * 
     * @param wxUser 微信用户信息
     * @return 微信用户集合
     */
	@Override
	public List<WxUser> selectWxUserList(WxUser wxUser)
	{
	    return wxUserMapper.selectWxUserList(wxUser);
	}
	
    /**
     * 新增微信用户
     * 
     * @param wxUser 微信用户信息
     * @return 结果
     */
	@Override
	public int insertWxUser(WxUser wxUser)
	{
	    return wxUserMapper.insertWxUser(wxUser);
	}
	
	/**
     * 修改微信用户
     * 
     * @param wxUser 微信用户信息
     * @return 结果
     */
	@Override
	public int updateWxUser(WxUser wxUser)
	{
	    return wxUserMapper.updateWxUser(wxUser);
	}

	/**
     * 删除微信用户对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteWxUserByIds(String ids)
	{
		return wxUserMapper.deleteWxUserByIds(Convert.toStrArray(ids));
	}

	@Override
	public List<WxUser> selectWxUserList1(WxUser wxUser) {
		List<WxUser> wxUsers = wxUserMapper.selectWxUserList(wxUser);
		/*for (WxUser user : wxUsers) {
			String id = user.getId();
			Double histotalmoney =wxUserMapper.selectHistotalMoney(id);
			Double totalmoney =wxUserMapper.selectTotalMoney(id);
			if(histotalmoney!=null){
				user.setHistoryTotalMoeney(histotalmoney);
			}
			if(totalmoney!=null){
				user.setTotalMoeney(totalmoney);
			}
		}*/
		return wxUsers;
	}

	@Override
	public WxUser selectWxUserByOpenId(String openid) {
		return  wxUserMapper.selectWxUserByOpenId(openid);

	}

	@Override
	public WxUser selectWxUserByPhone(String phone) {
		return  wxUserMapper.selectWxUserByPhone(phone);
	}

	@Override
	public List<WxUser> selectWxUserListPage(Integer pageSize, Integer from, String realName) {
		return  wxUserMapper.selectWxUserListPage(pageSize,from,realName);

	}

}
